#ifndef TRUCK_H_
#define TRUCK_H_

#include "sceneObject.h"
#include "model/actions/gravity.h"
#include "model/path.h"
#include "model/path_iterator.h"
#include "truckPathInfo.h"
#include "model/lighting.h"

class Truck : public SceneObject , public Solid , public IFollower{
	private:
		Path* path;
		PathIterator* iterator;
		bool stopped;
		bool loaded;
		float accel;
		float maxSpeed;
		float minSpeed;
		float zRotatedAngle;
		float xRotatedAngle;
		float zDiffRotated;
		float xDiffRotated;

		void getIteratorData();
	public:
		Truck(const Cube& chasis,const Cube& loadArea,const Point& dir,Path* path,const ObjectModelPtr& chasisModel,const ObjectModelPtr& tireModel,const ObjectModelPtr& loadAreaModel);
		~Truck();

		void timeStep();

		Point getDriverPosition();

		void setModelMatrix();
		void setSubModelMatrix(const std::string& name);

		void notifyCollision(Solid* obj);
		void notifyCollided(Solid* obj){}

		void notifySolidPositionChange(float vel=0);

		void updatePosition(const Point& position,const Point& direction,PathInfo* info);

		void unloadAreaReached(void*);
		void loadAreaReached(void*);

		// Angulo total rotado desde el plano yz
		float getZRotatedAngle(){
			return this->zRotatedAngle;
		}

		float getXRotatedAngle(){
			return this->xRotatedAngle;
		}


		// Angulo parcial rotado desde la ultima rotacion
		float getZDiffRotated(){
			return this->zDiffRotated;
		}

		float getXDiffRotated(){
			return this->xDiffRotated;
		}

		const PathIterator& getIterator(){
			return *this->iterator;
		}

		void setZRotatedAngle(float val){
			this->zDiffRotated=val-this->zRotatedAngle;
			this->zRotatedAngle=val;
		}

		void move(float dx,float dy,float dz);

		static std::string name(){
			return "truck";
		}
};

#endif /* TRUCK_H_ */
